public class Test01 {
    //throws声明异常
    public static void ThrowExample(int[] arr) throws NullPointerException,ArithmeticException,CloneNotSupportedException{//声明：可能抛出的异常
        if (arr==null){
            throw new NullPointerException();//抛出异常
        }
    }
    public static void main(String[] args) {
        System.out.println(1);
        try{
            //存放可能抛异常的代码
            ThrowExample(null);
            System.out.println(10/0);//该行代码不会被执行
        }catch(NullPointerException e){
            //异常类型               异常变量
            e.printStackTrace();//打印栈上信息
            System.out.println(" 捕获异常");
        }catch (CloneNotSupportedException e){
            System.out.println("catch CloneNotSupportedException");
        }catch (Exception e){//父类异常放所有异常最后
            System.out.println("catch Exception");//捕捉父类异常
        }finally {//无论是否发生异常，此处代码都会被执行
            System.out.println(" finally一定会被执行");
        }
        System.out.println("normal operate");
    }
}
